#import "UIBarButtonItem+WBCreate.h"
@implementation UIBarButtonItem (WBCreate)
+(UIBarButtonItem *)ct_itemWithTarget:(id)target action:(SEL)action image:(UIImage *)image {
    return [self ct_itemWithTarget:target action:action nomalImage:image higeLightedImage:nil imageEdgeInsets:UIEdgeInsetsZero];
}
+(UIBarButtonItem *)ct_itemWithTarget:(id)target action:(SEL)action image:(UIImage *)image imageEdgeInsets:(UIEdgeInsets)imageEdgeInsets {
    return [self ct_itemWithTarget:target action:action nomalImage:image higeLightedImage:nil imageEdgeInsets:imageEdgeInsets];
}
+(UIBarButtonItem *)ct_itemWithTarget:(id)target
                            action:(SEL)action
                        nomalImage:(UIImage *)nomalImage
                  higeLightedImage:(UIImage *)higeLightedImage
                   imageEdgeInsets:(UIEdgeInsets)imageEdgeInsets {
    UIButton *var_button = [UIButton buttonWithType:UIButtonTypeSystem];
    [var_button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [var_button setImage:[nomalImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    if (higeLightedImage) {
        [var_button setImage:higeLightedImage forState:UIControlStateHighlighted];
    }
    [var_button sizeToFit];
    CGFloat var_wh = 44;
    if (var_button.bounds.size.width < var_wh) {
        CGFloat var_width = var_wh / var_button.bounds.size.height * var_button.bounds.size.width;
        var_button.bounds = CGRectMake(0, 0, var_width, var_wh);
    }
    if (var_button.bounds.size.height > var_wh) {
        CGFloat var_height = var_wh / var_button.bounds.size.width * var_button.bounds.size.height;
        var_button.bounds = CGRectMake(0, 0, var_wh, var_height);
    }
    var_button.imageEdgeInsets = imageEdgeInsets;
    return [[UIBarButtonItem alloc] initWithCustomView:var_button];
}
+(UIBarButtonItem *)ct_itemWithTarget:(id)target action:(SEL)action title:(NSString *)title {
    return [self ct_itemWithTarget:target action:action title:title font:nil titleColor:nil highlightedColor:nil titleEdgeInsets:UIEdgeInsetsZero];
}
+(UIBarButtonItem *)ct_itemWithTarget:(id)target action:(SEL)action title:(NSString *)title titleEdgeInsets:(UIEdgeInsets)titleEdgeInsets {
    return [self ct_itemWithTarget:target action:action title:title font:nil titleColor:nil highlightedColor:nil titleEdgeInsets:titleEdgeInsets];
}
+(UIBarButtonItem *)ct_itemWithTarget:(id)target
                            action:(SEL)action
                             title:(NSString *)title
                              font:(UIFont *)font
                        titleColor:(UIColor *)titleColor
                  highlightedColor:(UIColor *)highlightedColor
                   titleEdgeInsets:(UIEdgeInsets)titleEdgeInsets {
    UIButton *var_button = [UIButton buttonWithType:UIButtonTypeSystem];
    [var_button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [var_button setTitle:title forState:UIControlStateNormal];
    var_button.titleLabel.font = font?font:nil;
    [var_button setTitleColor:titleColor?titleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [var_button setTitleColor:highlightedColor?highlightedColor:nil forState:UIControlStateHighlighted];
    [var_button sizeToFit];
    if (var_button.bounds.size.width < 40) {
        CGFloat var_width = 40 / var_button.bounds.size.height * var_button.bounds.size.width;
        var_button.bounds = CGRectMake(0, 0, var_width, 40);
    }
    if (var_button.bounds.size.height > 40) {
        CGFloat var_height = 40 / var_button.bounds.size.width * var_button.bounds.size.height;
        var_button.bounds = CGRectMake(0, 0, 40, var_height);
    }
    var_button.titleEdgeInsets = titleEdgeInsets;
    return [[UIBarButtonItem alloc] initWithCustomView:var_button];
}
+(UIBarButtonItem *)ct_fixedSpaceWithWidth:(CGFloat)width {
    UIBarButtonItem *var_fixedSpace = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
    var_fixedSpace.width = width;
    return var_fixedSpace;
}
@end
